package Level02_three;

import java.sql.Array;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Iterator;

public class Test {
    public static void main(String[] args) {
        //创建一个ArrayList集合，存储五个学生对象
        ArrayList<Object> arrayList = new ArrayList<>();
        //把五个学生对象传入数组
        Student student = new Student("小胡",22,100);
        Student student1 = new Student("小程",21,99);
        Student student2 = new Student("小向",20,98);
        Student student3 = new Student("小植",19,97);
        Student student4 = new Student("小威",18,96);
        arrayList.add(student);
        arrayList.add(student1);
        arrayList.add(student2);
        arrayList.add(student3);
        arrayList.add(student4);
        //定义总分
        int sum = 0;
        //定义最高分
        double max = student.getScore();
        //定义最低分
        double min = student.getScore();
        Iterator<Object> iterator = arrayList.iterator();
        while(iterator.hasNext()){
            Object next = iterator.next();
            if(next instanceof Student){
                Student student5 = (Student) next;
                sum += student5.getScore();
                if(max < student5.getScore()){
                    max = student5.getScore();
                }
                if(min > student5.getScore()){
                    min = student5.getScore();
                }
            }
        }
        System.out.println("总分：" + sum);
        System.out.println("最高分：" + max);
        System.out.println("最低分：" + min);

    }
}
